<?php
// Returns the plan of study for a specific student.

session_start();
if ( ! isset( $_SESSION['studentLoggedIn'] ) ) {
   exit;
}

require_once("db.php");

// Is there data coming in?
if ( isset($_GET['primaryKey'] ) ) {
   
   $primaryKey = $_GET['primaryKey'];
   
   $sql = "
      SELECT 
         id,
         is_approved,
         is_submitted,
         is_reviewed,
         comments,
         allowable,
         xml as plan
      FROM gs_plans
      WHERE student_id='$primaryKey'
   ";
  
   $result = my_mysql_query($sql);
   if ( mysql_num_rows( $result ) > 0 ) {

      $row = mysql_fetch_assoc($result);
 
      // Output the result as XML.
      echo "<planofstudy>\n";
      foreach (array_keys($row) as $key) {
         echo "<$key>";
         echo stripslashes($row[$key]); 
         echo "</$key>\n";
      }
      echo "</planofstudy>\n";
   }
}
?>